import os

from src.predict import model_predict
from src.train import PowerLoadModel, analysis_data, data_processing, model_train

if __name__ == '__main__':
    # 1.加载数据集
    input_file = os.path.join(os.path.abspath('../data'), 'train.csv')  # 绝对路径处理
    model = PowerLoadModel(input_file)
    model.logfile.info(f"成功加载训练数据: {input_file}，数据形状: {model.data_source.shape}")

    # 2.分析数据
    analysis_result = analysis_data(model.data_source, model.logfile)  # 增加日志参数
    model.logfile.info(f"数据特征AUC分析结果: {analysis_result[:5]}...")  # 展示部分结果

    # 3.特征工程
    x_train, y_train, scaler = data_processing(model.data_source, model.logfile)  # 接收scaler
    model.logfile.info(f"特征工程完成，训练特征形状: {x_train.shape}")

    # 4.模型训练、评价与保存
    model_train(x_train, y_train, model.logfile)
    model.logfile.info("模型训练流程完成")

    # 5.模型预测
    model_predict('test.csv', model.logfile)  # 传递日志器